/**
 * 产品接口
 */
import {
  HTTP
} from '../utils/http.js';
import utils from '../utils/util';

class productModel extends HTTP {
  // 查询报价列表
  listQuotePage(data, sCallback, showLoading) {
    this.request({
      url: 'supplier/app/product/listPage',
      method: 'get',
      data: data,
      success: (res) => {
        if(res.code == 200){
          sCallback(res)
        }else{
          utils.msg(res.msg)
        }
      }
    },'',showLoading)
  }
  // 查询产品详情
  productFindById(data, sCallback) {
    this.request({
      url: 'supplier/app/product/findById',
      method: 'get',
      data: data,
      success: (res) => {
        if(res.code == 200){
          sCallback(res)
        }else{
          utils.msg(res.msg)
        }
      }
    })
  }
  
  // 查询产品改价记录
  listProductUpdatePriceRecord(data, sCallback) {
    this.request({
      url: 'supplier/app/product/listProductUpdatePriceRecord',
      method: 'get',
      data: data,
      success: (res) => {
        if(res.code == 200){
          sCallback(res)
        }else{
          utils.msg(res.msg)
        }
      }
    })
  }

  // 报价
  productQuote(data, sCallback) {
    this.request({
      url: 'supplier/app/product/quote',
      method: 'post',
      data: data,
      success: (res) => {
        if(res.code == 200){
          sCallback(res)
        }else{
          utils.msg(res.msg)
        }
      }
    }, 'postJson')
  }

  // 查询所有类别
  categoryListAll(sCallback) {
    this.request({
      url: 'supplier/app/product/category/listAll',
      method: 'get',
      data: {},
      success: (res) => {
        if(res.code == 200){
          sCallback(res)
        }else{
          utils.msg(res.msg)
        }
      }
    })
  }

  // 查询搜索记录
  recordListPage(sCallback) {
    this.request({
      url: 'supplier/app/search/record/listPage',
      method: 'get',
      data: {
        page: 1,
        limit: 10,
        type: 2
      },
      success: (res) => {
        if(res.code == 200){
          sCallback(res)
        }else{
          utils.msg(res.msg)
        }
      }
    })
  }

  // 产品改价前价格
  lastProductPrice(data, sCallback) {
    this.request({
      url: 'supplier/app/product/lastProductPrice',
      method: 'get',
      data: data,
      success: (res) => {
        if(res.code == 200){
          sCallback(res)
        }else{
          utils.msg(res.msg)
        }
      }
    })
  }

  // 上架
  shelfUp(data, sCallback) {
    this.request({
      url: 'supplier/app/product/shelf/up',
      method: 'post',
      data: data,
      success: (res) => {
        if(res.code == 200){
          sCallback(res)
        }else{
          utils.msg(res.msg)
        }
      }
    })
  }
  // 下架
  shelfDown(data, sCallback) {
    this.request({
      url: 'supplier/app/product/shelf/down',
      method: 'post',
      data: data,
      success: (res) => {
        if(res.code == 200){
          sCallback(res)
        }else{
          utils.msg(res.msg)
        }
      }
    })
  }

  // 食堂等级
  labelListAll(sCallback) {
    this.request({
      url: 'supplier/app/label/listAll',
      method: 'get',
      data: {
        page: 1,
        limit: 10
      },
      success: (res) => {
        if(res.code == 200){
          sCallback(res.data)
        }else{
          utils.msg(res.msg)
        }
      }
    })
  }
}
export {
  productModel
}